package com.sc.service.impl.vehicle;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.domain.VehicleCost;
import com.sc.mapper.VehicleCostMapper;
import com.sc.service.vehicle.IVehicleCostService;
import org.springframework.stereotype.Service;

@Service
public class IVehicleCostServiceImpl extends ServiceImpl<VehicleCostMapper, VehicleCost>
          implements IVehicleCostService {
    @Override
    public Boolean addVehicleCost(VehicleCost vehicleCost) {
        return save(vehicleCost);
    }

    @Override
    public Page<VehicleCost> showCosts(String positionName, Integer pageNum, Integer pageSize) {
        Page<VehicleCost> page = Page.of(pageNum,pageSize);
        QueryWrapper<VehicleCost> wrapper = new QueryWrapper<>();
        if (positionName != null)
        {
            wrapper.like("position",positionName)
                    .or()
                    .like("region",positionName);
        }
        page(page,wrapper);
        return page;
    }
}
